import { defHttp } from '@/utils/http/axios';

enum Api {
  GetContractTemplateList = '/findContractSign',
  UpdateContractInfo = '/updateContractSign',
  AddContractInfo = '/addContractSign',
}

const defState = {
  id: '',
  doctorName: '',
  doctorId: '',
  doctorIdentity: '',
  address: '',
  esignId: '',
  conpanyName: '',
  signTime: '',
  beginTime: '',
  endTime: '',
  pdfImg: '',
  mobile: '',
  state: 1,
}

export type ContractListItemType = typeof defState

export const getContractList = (data?) => {
  return defHttp.post<ContractListItemType[]>({
    url: Api.GetContractTemplateList,
    data
  });
};

export const getContractInfoApi = (id) => {
  return getContractList({ id }).then(res => {
    return res?.[0] || {}
  })
};

export const addContractInfoApi = (data) => {
  return defHttp.post({
    url: Api.AddContractInfo,
    data: Object.assign(defState, data)
  });
};

export const updateContractInfoApi = (data) => {
  return defHttp.put({
    url: Api.UpdateContractInfo,
    data: data
  });
};